package com.ext.portlet.registration.action;

import java.io.File;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.ext.portlet.city.service.CityLocalServiceUtil;
import com.ext.portlet.community.model.CommunityExtra;
import com.ext.portlet.community.model.impl.CommunityExtraImpl;
import com.ext.portlet.community.service.CommunityExtraLocalServiceUtil;
import com.ext.portlet.registration.DuplicateEmployeeIdException;
import com.ext.portlet.registration.DuplicateRollNoException;
import com.ext.portlet.registration.SecretPinException;
import com.ext.portlet.registration.model.CollOthers;
import com.ext.portlet.registration.model.CollStudent;
import com.ext.portlet.registration.model.College;
import com.ext.portlet.registration.model.Others;
import com.ext.portlet.registration.model.School;
import com.ext.portlet.registration.model.Staff;
import com.ext.portlet.registration.model.Teacher;
import com.ext.portlet.registration.model.impl.CollOthersImpl;
import com.ext.portlet.registration.model.impl.CollStudentImpl;
import com.ext.portlet.registration.model.impl.CollegeImpl;
import com.ext.portlet.registration.model.impl.StaffImpl;
import com.ext.portlet.registration.service.CollOthersLocalServiceUtil;
import com.ext.portlet.registration.service.CollStudentLocalServiceUtil;
import com.ext.portlet.registration.service.CollegeLocalServiceUtil;
import com.ext.portlet.registration.service.SchoolLocalServiceUtil;
import com.ext.portlet.registration.service.StaffLocalServiceUtil;
import com.ext.portlet.registration.util.RegistrationActionUtil;
import com.liferay.counter.service.persistence.CounterUtil;
import com.liferay.portal.ContactBirthdayException;
import com.liferay.portal.DuplicateGroupException;
import com.liferay.portal.DuplicateUserEmailAddressException;
import com.liferay.portal.DuplicateUserScreenNameException;
import com.liferay.portal.GroupFriendlyURLException;
import com.liferay.portal.GroupNameException;
import com.liferay.portal.NoSuchGroupException;
import com.liferay.portal.NoSuchUserException;
import com.liferay.portal.PortalException;
import com.liferay.portal.RequiredGroupException;
import com.liferay.portal.ReservedUserScreenNameException;
import com.liferay.portal.SystemException;
import com.liferay.portal.UserScreenNameException;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.util.CharPool;
import com.liferay.portal.kernel.util.Constants;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.InstancePool;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.Contact;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.Layout;
import com.liferay.portal.model.User;
import com.liferay.portal.model.UserGroup;
import com.liferay.portal.model.impl.LayoutImpl;
import com.liferay.portal.security.auth.ScreenNameValidator;
import com.liferay.portal.service.AddressLocalServiceUtil;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.GroupServiceUtil;
import com.liferay.portal.service.LayoutLocalServiceUtil;
import com.liferay.portal.service.PhoneServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserGroupLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.service.UserServiceUtil;
import com.liferay.portal.service.base.PrincipalBean;
import com.liferay.portal.service.persistence.UserGroupUtil;
import com.liferay.portal.struts.PortletAction;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portal.util.FriendlyURLNormalizer;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portal.util.PrefsPropsUtil;
import com.liferay.portal.util.PropsKeys;
import com.liferay.portal.util.PropsValues;
import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil;

public class CampusRegistration extends PortletAction{
	
	public void processAction(
			ActionMapping mapping, ActionForm form, PortletConfig config,
			ActionRequest req, ActionResponse res)
				throws Exception {
		
		HttpServletRequest request = PortalUtil.getHttpServletRequest(req);
        ThemeDisplay theme = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
        long cId = theme.getCompanyId();
        
		String cmd = ParamUtil.getString(req, Constants.CMD);		
		
		if (cmd.equals(Constants.MOVE)) {
			String registration = req.getParameter("registration");							
			
			if(registration != null && registration.equals("1")){
				setForward(req, "portlet.ext.registration.campus.collegeForm");				
			}else if(registration != null && registration.equals("2")){
				setForward(req, "portlet.ext.registration.campus.collStudent");
			}else if(registration != null && registration.equals("3")){
				setForward(req, "portlet.ext.registration.campus.staff");
			}else if(registration != null && registration.equals("4")){
				setForward(req, "portlet.ext.registration.campus.collOthersForm");
			}else{
				setForward(req, "portlet.ext.registration.view");
			}
		}

		if (cmd.equals("addCollege")) {
			addCollege(req, cId);
		}
		
		// to check whether the school exists 
		if (cmd.equals("validCollStudent")) {
			validCollStudent(req);				
		}
		
		if(cmd.equals("addCollStudent")){
			addCollStudent(req, cId);
		}	
		
		if (cmd.equals("validStaff")) {
			validStaff(req);
		}
		
		if(cmd.equals("addStaff")) {
			addStaff(req, cId);
		}
		
		if (cmd.equals("addCollOthers")) {				
			addCollOthers(req, cId);
		}
		
		if(cmd.equals("createCollege")) {
			createCollege(req);
		}
		
		if(cmd.equals("createCollStudent")) {
			createCollStudent(req);
		}
		
		//Approve College and enter Secret Pin
		if(cmd.equals("approveCollege")){	
			approveCollege(req, cId);
		}
		
		if(cmd.equals("approveCollStudent")) { 
			approveCollStudent(req, cId);
		}
		
		if(cmd.equals("approveCollOthers")) { 
			approveCollOthers(req, cId);
		}
		
		if(cmd.equals("approveStaff")) { 
			approveStaff(req, cId);
		}
		
		// View Begin 
		if(cmd.equals("viewCollege")){	
			viewCollege(req);	
		}
		
		if(cmd.equals("viewCollStudent")){				
			viewCollStudent(req);
		}
		
		if(cmd.equals("viewStaff")){				
			viewStaff(req);
		}
		
		if(cmd.equals("viewCollOthers")){				
			viewCollOthers(req);
		}
		// view End
		
		if(cmd.equals("removeCollege")) {
			removeCollege(req);
		}

		if(cmd.equals("removeCollStudent")) {
			removeCollStudent(req);
		}
		
		if(cmd.equals("removeStaff")) {
			removeStaff(req);
		}
		
		if(cmd.equals("removeCollOther")) {
			removeCollOther(req);
		}
		
		if(cmd.equals("pendingCollege")) {
			pendingCollege(req);
		}
		
		if(cmd.equals("rejectCollege")) {
			rejectCollege(req);
		}
		
		if(cmd.equals("pendingCollStudent")) {
			pendingCollStudent(req);
		}
		
		if(cmd.equals("rejectCollStudent")) {
			rejectCollStudent(req);
		}
		
		if(cmd.equals("pendingStaff")) {
			pendingStaff(req);
		}
		
		if(cmd.equals("rejectStaff")) {
			rejectStaff(req);
		}
		
		if(cmd.equals("pendingCollOthers")) {
			pendingCollOthers(req);
		}
		
		if(cmd.equals("rejectCollOthers")) {
			rejectCollOthers(req);
		}
	}

	protected void validateScreenName(long companyId, String screenName)
		throws PortalException, SystemException {

		if (Validator.isNull(screenName)) {
			throw new UserScreenNameException();
		}

		ScreenNameValidator screenNameValidator =
			(ScreenNameValidator)InstancePool.get(
				PropsValues.USERS_SCREEN_NAME_VALIDATOR);

		if (screenNameValidator != null) {
			if (!screenNameValidator.validate(companyId, screenName)) {
				throw new UserScreenNameException();
			}
		}

		if (Validator.isNumber(screenName) ) {
			throw new UserScreenNameException();
		}

		for (char c : screenName.toCharArray()) {
			if ((!Validator.isChar(c)) && (!Validator.isDigit(c)) &&
				(c != CharPool.DASH) && (c != CharPool.PERIOD) &&
				(c != CharPool.UNDERLINE)) {

				throw new UserScreenNameException();
			}
		}

		String[] anonymousNames = PrincipalBean.ANONYMOUS_NAMES;

		for (int i = 0; i < anonymousNames.length; i++) {
			if (screenName.equalsIgnoreCase(anonymousNames[i])) {
				throw new UserScreenNameException();
			}
		}
		User user = null;
		try{
		 user = UserLocalServiceUtil.getService().getUserByScreenName(companyId, screenName);
		}catch(NoSuchUserException ex){
			//
		}
		
		//User user = userPersistence.fetchByC_SN(companyId, screenName);

		if (user != null) {
			throw new DuplicateUserScreenNameException();
		}

		String friendlyURL = StringPool.SLASH + screenName;
		Group group = null;
		try{
		 group = GroupLocalServiceUtil.getService().getFriendlyURLGroup(companyId, friendlyURL);
		}catch(NoSuchGroupException ge){
			//
		}
		//Group group = groupPersistence.fetchByC_F(companyId, friendlyURL);

		if (group != null) {
			throw new DuplicateUserScreenNameException();
		}

		int exceptionType = LayoutImpl.validateFriendlyURL(friendlyURL);

		if (exceptionType != -1) {
			throw new UserScreenNameException(
				new GroupFriendlyURLException(exceptionType));
		}

		String[] reservedScreenNames = PrefsPropsUtil.getStringArray(
			companyId, PropsKeys.ADMIN_RESERVED_SCREEN_NAMES,
			StringPool.NEW_LINE, PropsValues.ADMIN_RESERVED_SCREEN_NAMES);

		for (int i = 0; i < reservedScreenNames.length; i++) {
			if (screenName.equalsIgnoreCase(reservedScreenNames[i])) {
				throw new ReservedUserScreenNameException();
			}
		}
	}

	protected void validateName(String name)
	throws PortalException, SystemException {

	if ((Validator.isNull(name)) || (Validator.isNumber(name)) ||
		(name.indexOf(StringPool.COMMA) != -1) ||
		(name.indexOf(StringPool.STAR) != -1)) {
		throw new GroupNameException();
		}				
	}
	

	private void viewCollOthers(ActionRequest req) throws PortalException,
		SystemException {
	Long collOthersIds = Long.parseLong(req.getParameter("collOthersId"));				
	CollOthers collOthers = CollOthersLocalServiceUtil.getCollOthers(collOthersIds);
	req.setAttribute("CollOthers", collOthers);
	setForward(req, "portlet.ext.registration.campus.viewCollOthersDetails");
	}
	/**
	* @param req
	* @throws PortalException
	* @throws SystemException
	*/
	private void viewStaff(ActionRequest req) throws PortalException,
		SystemException {
	Long staffId = Long.parseLong(req.getParameter("staffId"));
	Staff staff = StaffLocalServiceUtil.getStaff(staffId);
	req.setAttribute("Staff", staff);
	setForward(req, "portlet.ext.registration.campus.viewStaffDetails");
	}
	/**
	* @param req
	* @throws PortalException
	* @throws SystemException
	*/
	private void viewCollStudent(ActionRequest req) throws PortalException,
		SystemException {
	Long collStudentId = Long.parseLong(req.getParameter("collStudentId"));				
	CollStudent collStudent = CollStudentLocalServiceUtil.getCollStudent(collStudentId);
	req.setAttribute("CollStudent", collStudent);
	setForward(req, "portlet.ext.registration.campus.viewCollStudentDetails");
	}
	/**
	* @param req
	* @throws PortalException
	* @throws SystemException
	*/
	private void viewCollege(ActionRequest req) throws PortalException,
		SystemException {
	String button = req.getParameter("approve");
	Long collegeId = Long.parseLong(req.getParameter("collegeId"));				
	College college = CollegeLocalServiceUtil.getCollege(collegeId);
	
	if(Validator.isNotNull(button)) {
		req.setAttribute("Button", button);
	}
	
	req.setAttribute("College", college);
	setForward(req, "portlet.ext.registration.campus.viewCollegeDetails");
	}
	/**
	* @param req
	* @param cId
	* @throws PortalException
	* @throws SystemException
	* @throws Exception
	*/
	private void removeCollege(ActionRequest req) throws PortalException,
	    SystemException {
	Long collegeId = Long.parseLong(req.getParameter("collegeId"));
	College college = CollegeLocalServiceUtil.getCollege(collegeId);
	college.setStatus(4);
	CollegeLocalServiceUtil.updateCollege(college);
	req.setAttribute("College", college);
	setForward(req, "portlet.ext.registration.campus.success");
	}
	
	private void removeCollStudent(ActionRequest req) throws PortalException,
		SystemException {
	Long collStudentId = Long.parseLong(req.getParameter("collStudentId"));
	CollStudent collStudent = CollStudentLocalServiceUtil.getCollStudent(collStudentId);
	collStudent.setStatus(4);
	CollStudentLocalServiceUtil.updateCollStudent(collStudent);
	req.setAttribute("CollStudent", collStudent);
	setForward(req, "portlet.ext.registration.campus.success");
	}
	
	private void removeStaff(ActionRequest req) throws PortalException,
		SystemException {
	Long staffId = Long.parseLong(req.getParameter("staffId"));
	Staff staff = StaffLocalServiceUtil.getStaff(staffId);
	staff.setStatus(4);
	StaffLocalServiceUtil.updateStaff(staff);
	req.setAttribute("Staff", staff);
	setForward(req, "portlet.ext.registration.campus.success");
	}
	
	private void removeCollOther(ActionRequest req) throws PortalException,
		SystemException {
	Long collOtherId = Long.parseLong(req.getParameter("collOtherId"));
	CollOthers collOthers = CollOthersLocalServiceUtil.getCollOthers(collOtherId);
	collOthers.setStatus(4);
	CollOthersLocalServiceUtil.updateCollOthers(collOthers);
	req.setAttribute("CollOthers", collOthers);
	setForward(req, "portlet.ext.registration.campus.success");
	}
	
	private void approveStaff(ActionRequest req, long cId)
		throws PortalException, SystemException, Exception {
	Long staffId = Long.parseLong(req.getParameter("staffId"));		
	Staff staff = StaffLocalServiceUtil.getStaff(staffId);		
	
	Date birthday = staff.getBirthDay();
	Calendar cal = Calendar.getInstance();
	cal.setTime(birthday);
	int birthdayMonth = cal.get(Calendar.MONTH);
	int birthdayDay = cal.get(Calendar.DAY_OF_MONTH);
	int birthdayYear = cal.get(Calendar.YEAR);
	
	User newUser = createUser(cId, staff.getLoginId(), staff.getFirstName(), 
			staff.getMiddleName(), staff.getLastName(), staff.getGender(),  
			birthdayMonth, birthdayDay, birthdayYear, staff.getEmailAddress(),staff.getJobTitle(), "staff");
	
	long countryId = Long.parseLong(staff.getCountry());
	long regionId = Long.parseLong(staff.getState());
	String city = CityLocalServiceUtil.cityName(Long.parseLong(staff.getCity()));
	
	AddressLocalServiceUtil.addAddress(newUser.getUserId(), Contact.class.getName(), 
			newUser.getContactId(), staff.getStreet1(), staff.getStreet2(), staff.getStreet3(), city, 
			staff.getPinCode(), regionId, countryId, 11002, false, true);
	
	
	PhoneServiceUtil.addPhone(
			Contact.class.getName(), newUser.getContactId(), staff.getContactNo(), StringPool.BLANK,
			11008, true);
	
	College college = CollegeLocalServiceUtil.getCollege(staff.getCollegeId());
	long userIds[] = {newUser.getUserId()};
	long groupId = college.getGroupId();
	
	UserLocalServiceUtil.addGroupUsers(groupId, userIds);	
			
	UserGroup userGroup = UserGroupLocalServiceUtil.getUserGroup(cId, "Campus");
	
	UserGroupUtil.addUser(userGroup.getUserGroupId(), newUser.getPrimaryKey());
	
	staff.setStatus(1);
	staff.setUserId(newUser.getUserId());
	StaffLocalServiceUtil.updateStaff(staff);
	
	// Loading LAR for User Pages by AYAZ		
	RegistrationActionUtil.addDefaultUserPublicLayouts(newUser);
	
	req.setAttribute("Staff", staff);
	setForward(req, "portlet.ext.registration.campus.success");
	}
	/**
	* @param req
	* @param cId
	* @throws PortalException
	* @throws SystemException
	* @throws Exception
	*/
	private void approveCollOthers(ActionRequest req, long cId)
		throws PortalException, SystemException, Exception {
	Long collOthersId = Long.parseLong(req.getParameter("collOthersId"));		
	CollOthers collOthers = CollOthersLocalServiceUtil.getCollOthers(collOthersId);
	
	Date birthday = collOthers.getBirthDay();
	Calendar cal = Calendar.getInstance();
	cal.setTime(birthday);
	int birthdayMonth = cal.get(Calendar.MONTH);
	int birthdayDay = cal.get(Calendar.DAY_OF_MONTH);
	int birthdayYear = cal.get(Calendar.YEAR);
	
	User newUser = createUser(cId, collOthers.getLoginId(), collOthers.getFirstName(),
			collOthers.getMiddleName(), collOthers.getLastName(), collOthers.getGender(),  
			birthdayMonth, birthdayDay, birthdayYear, collOthers.getEmailAddress(),collOthers.getJobTitle(), "collOthers");
	
	long countryId = Long.parseLong(collOthers.getCountry());
	long regionId = Long.parseLong(collOthers.getState());
	String city = CityLocalServiceUtil.cityName(Long.parseLong(collOthers.getCity()));
	
	AddressLocalServiceUtil.addAddress(newUser.getUserId(), Contact.class.getName(), 
			newUser.getContactId(), collOthers.getStreet1(), collOthers.getStreet2(), collOthers.getStreet3(),
			city, collOthers.getPinCode(), regionId, countryId, 11002, false, true);
	
	PhoneServiceUtil.addPhone(
			Contact.class.getName(), newUser.getContactId(), collOthers.getContactNo(), StringPool.BLANK,
			11008, true);
	
	collOthers.setStatus(1);
	collOthers.setUserId(newUser.getUserId());
	CollOthersLocalServiceUtil.updateCollOthers(collOthers);
	
	// Loading LAR for User Pages by AYAZ		
	RegistrationActionUtil.addDefaultUserPublicLayouts(newUser);
	
	req.setAttribute("CollOthers", collOthers);
	setForward(req, "portlet.ext.registration.campus.success");
	}
	/**
	* @param req
	* @param cId
	* @throws PortalException
	* @throws SystemException
	* @throws Exception
	*/
	private void approveCollStudent(ActionRequest req, long cId)
		throws PortalException, SystemException, Exception {
	Long collStudentId = Long.parseLong(req.getParameter("collStudentId"));		
	CollStudent collStudent = CollStudentLocalServiceUtil.getCollStudent(collStudentId);
				
	String emailAddress = collStudent.getLoginId()+StringPool.AT+"bench-mark.org";
	
	Date birthday = collStudent.getBirthDay();
	Calendar cal = Calendar.getInstance();
	cal.setTime(birthday);
	int birthdayMonth = cal.get(Calendar.MONTH);
	int birthdayDay = cal.get(Calendar.DAY_OF_MONTH);
	int birthdayYear = cal.get(Calendar.YEAR);
	
	
	User newUser = createUser(cId, collStudent.getLoginId(), collStudent.getFirstName(), 
			collStudent.getMiddleName(), collStudent.getLastName(), collStudent.getGender(), 
			birthdayMonth, birthdayDay, birthdayYear, emailAddress,collStudent.getDegree(), "collStudent");
	
	long countryId = Long.parseLong(collStudent.getCountry());
	long regionId = Long.parseLong(collStudent.getState());
	String city = CityLocalServiceUtil.cityName(Long.parseLong(collStudent.getCity()));
	
	AddressLocalServiceUtil.addAddress(newUser.getUserId(), Contact.class.getName(), 
			newUser.getContactId(), collStudent.getStreet1(), collStudent.getStreet2(), collStudent.getStreet3(),
			city, collStudent.getPinCode(), regionId, countryId, 11002, false, true);
	
	PhoneServiceUtil.addPhone(
			Contact.class.getName(), newUser.getContactId(), collStudent.getContactNo(), StringPool.BLANK,
			11008, true);
	
	College college = CollegeLocalServiceUtil.getCollege(collStudent.getCollegeId());
	long userIds[] = {newUser.getUserId()};
	long groupId = college.getGroupId();
	
	UserLocalServiceUtil.addGroupUsers(groupId, userIds);	
	
	UserGroup userGroup = UserGroupLocalServiceUtil.getUserGroup(cId, "Campus");
	
	UserServiceUtil.addUserGroupUsers(userGroup.getUserGroupId(), userIds);
	
	collStudent.setStatus(1);
	collStudent.setUserId(newUser.getUserId());
	CollStudentLocalServiceUtil.updateCollStudent(collStudent);
	
	// Loading LAR for User Pages by AYAZ		
	RegistrationActionUtil.addDefaultUserPublicLayouts(newUser);
	
	req.setAttribute("student", collStudent);
	setForward(req, "portlet.ext.registration.campus.success");
	}
	/**
	* @param req
	* @param cId
	* @throws PortalException
	* @throws SystemException
	* @throws Exception
	*/
	private void approveCollege(ActionRequest req, long cId)
		throws PortalException, SystemException, Exception {
	Long collegeId = Long.parseLong(req.getParameter("collegeId"));				
	College college = CollegeLocalServiceUtil.getCollege(collegeId);
	String secretPin = req.getParameter("secretPin");		
	
	Date birthday = college.getBirthDay();
	Calendar cal = Calendar.getInstance();
	cal.setTime(birthday);
	int birthdayMonth = cal.get(Calendar.MONTH);
	int birthdayDay = cal.get(Calendar.DAY_OF_MONTH);
	int birthdayYear = cal.get(Calendar.YEAR);
	
	if(secretPin != null) {
		
		School schoolList=null;
		try {
			schoolList=	SchoolLocalServiceUtil.secretPinValidation(secretPin);
			
			if(schoolList!= null) {
				req.setAttribute("College", college);
				
				throw new SecretPinException();
			}else{
				//approve logic put here
				
				User newUser = createUser(cId, college.getLoginId(), college.getCpFirstName(),
						college.getCpMiddleName(), college.getCpLastName(),  college.getCpGender(),
						birthdayMonth, birthdayDay, birthdayYear, college.getCpEmailAddress(), college.getJobTitle(), "college");
				
				long countryId = Long.parseLong(college.getCountry());
				long regionId = Long.parseLong(college.getState());
				String city = CityLocalServiceUtil.cityName(Long.parseLong(college.getCity()));
				
				
				AddressLocalServiceUtil.addAddress(newUser.getUserId(), Contact.class.getName(), 
						newUser.getContactId(), college.getStreet1(), college.getStreet2(), college.getStreet3(),
						city, college.getPinCode(), regionId, countryId, 11002, false, true);
			
				PhoneServiceUtil.addPhone(
						Contact.class.getName(), newUser.getContactId(), college.getContactNo(), StringPool.BLANK,
						11008, true);
				
				college.setSecretPin(secretPin);
				college.setUserId(newUser.getUserId());
				college.setStatus(1);
				
				String communityName = college.getName().trim();
				String friendlyURL = StringPool.SLASH + communityName.toLowerCase();
				
				// Creating Community 
				// not check Duplicate communityName && friendlyURL
				Group group = GroupServiceUtil.addGroup(communityName,"description", 
						3, friendlyURL, true);
				college.setGroupId(group.getGroupId());
				college = CollegeLocalServiceUtil.updateCollege(college);
				
				CommunityExtra communityExtra = new CommunityExtraImpl();
				communityExtra.setNew(true);
				communityExtra.setCommunityId(CounterUtil.increment(CommunityExtra.class.getName()));
				communityExtra.setCompanyId(cId);
				communityExtra.setGroupId(group.getGroupId());
				communityExtra.setName(group.getName());
				communityExtra.setCreateDate(new Date());
				communityExtra.setType(2);
				communityExtra.setCategory(2);
				CommunityExtraLocalServiceUtil.addCommunityExtra(communityExtra);
									
				long userIds[]={newUser.getUserId()};
				UserLocalServiceUtil.addGroupUsers(group.getGroupId(), userIds);
				
	
				File larFile = RegistrationActionUtil.getCampusDefaultLar();
				RegistrationActionUtil.addDefaultLayoutsByLAR(newUser.getUserId(), group.getGroupId(), false, larFile);
														
				UserGroup userGroup = UserGroupLocalServiceUtil.getUserGroup(cId, "Campus");
				
				UserLocalServiceUtil.addUserGroupUsers(userGroup.getUserGroupId(), userIds);
				
				// Loading LAR for User Pages by AYAZ		
				RegistrationActionUtil.addDefaultUserPublicLayouts(newUser);
				
				req.setAttribute("College", college);	
				setForward(req, "portlet.ext.registration.campus.success");
			}
			
		}catch(Exception e){
			log.info(e);
			
			if(e instanceof SecretPinException){
				SessionErrors.add(req, e.getClass().getName(), e);
			}else if (e instanceof DuplicateGroupException ||
					 e instanceof GroupFriendlyURLException ||
					 e instanceof GroupNameException ||
					 e instanceof RequiredGroupException) {
	
				SessionErrors.add(req, e.getClass().getName(), e);
				e.printStackTrace();
			}else {
				throw e;
			}
			setForward(req, "portlet.ext.registration.campus.viewCollegeDetails");
		}
	}
	}
	/**
	* @param req
	* @throws PortalException
	* @throws SystemException
	*/
	private void createCollStudent(ActionRequest req) throws PortalException,
		SystemException {
	String collStudentId = req.getParameter("collStudentId");
	CollStudent collStudent = CollStudentLocalServiceUtil.getCollStudent(Long.valueOf(collStudentId));
	collStudent.setStatus(1);
	CollStudentLocalServiceUtil.getService().updateCollStudent(collStudent);
	setForward(req, "portlet.ext.registration.view");
	}
	/**
	* @param req
	* @throws PortalException
	* @throws SystemException
	*/
	private void createCollege(ActionRequest req) throws PortalException,
		SystemException {
	String collegeId = req.getParameter("collegeId");
	College college = CollegeLocalServiceUtil.getCollege(Long.valueOf(collegeId));
	college.setStatus(1);
	CollegeLocalServiceUtil.getService().updateCollege(college);
	setForward(req, "portlet.ext.registration.view");
	}
	/**
	* @param req
	* @param cId
	* @throws SystemException
	* @throws Exception
	*/
	private void addCollOthers(ActionRequest req, long cId) throws SystemException,
		Exception {
	String firstName = req.getParameter("firstName");
	String middleName = req.getParameter("middleName");
	String lastName = req.getParameter("lastName");
	Boolean gender = ParamUtil.getBoolean(req, "gender");
	String jobTitle = req.getParameter("jobTitle");
	String street1 = req.getParameter("street1");
	String street2 = req.getParameter("street2");
	String street3 = req.getParameter("street3");
	String country = req.getParameter("countryId");
	String state = req.getParameter("regionId");
	String city = req.getParameter("cityId");
	String pinCode = req.getParameter("pinCode");
	String contactNo = req.getParameter("contactNo");
	String emailAddress = req.getParameter("emailId");
	String howUKnow = req.getParameter("howUKnow");
	String loginName = req.getParameter("loginName");
	int birthdayMonth = ParamUtil.getInteger(req, "birthdayMonth");
	int birthdayDay = ParamUtil.getInteger(req, "birthdayDay");
	int birthdayYear = ParamUtil.getInteger(req, "birthdayYear");
	Date birthDay = PortalUtil.getDate(
			birthdayMonth, birthdayDay, birthdayYear,
			new ContactBirthdayException());
	
	CollOthers collOtherEmailValidation = CollOthersLocalServiceUtil.EmailValidation(emailAddress);
	
	
	try{				
		validateScreenName(cId, loginName);
		
		if(Validator.isNotNull(collOtherEmailValidation)){
			throw new DuplicateUserEmailAddressException();
		}else{					
		CollOthers collOthers = new CollOthersImpl();
		collOthers.setPrimaryKey(CounterUtil.increment(Others.class.getName()));
		collOthers.setNew(true);
		collOthers.setFirstName(firstName);
		collOthers.setMiddleName(middleName);
		collOthers.setLastName(lastName);
		collOthers.setGender(gender);
		collOthers.setBirthDay(birthDay);
		collOthers.setJobTitle(jobTitle);
		collOthers.setStreet1(street1);
		collOthers.setStreet2(street2);
		collOthers.setStreet3(street3);
		collOthers.setCountry(country);
		collOthers.setState(state);
		collOthers.setCity(city);
		collOthers.setPinCode(pinCode);
		collOthers.setContactNo(contactNo);
		collOthers.setEmailAddress(emailAddress);
		collOthers.setHowUKnow(howUKnow);
		collOthers.setLoginId(loginName);
		
		collOthers.setCreateDate(new Date());
		collOthers.setStatus(0);
		
		CollOthersLocalServiceUtil.getService().addCollOthers(collOthers);				
		
		SessionMessages.add(req, "Registered Successfully");				
		setForward(req, "portlet.ext.registration.campus.success");
		}
	}catch(Exception e){
		if(e instanceof DuplicateUserEmailAddressException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else if(e instanceof DuplicateUserScreenNameException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else if(e instanceof UserScreenNameException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else if(e instanceof ReservedUserScreenNameException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else{
			throw e;
		}						
		setForward(req, "portlet.ext.registration.campus.collOthers");		
	}
	}
	/**
	* @param req
	* @throws SystemException
	* @throws Exception
	*/
	private void addStaff(ActionRequest req, long cId) throws SystemException,
		Exception {
	String employeeId = req.getParameter("employeeId");
	String collegeId = req.getParameter("collegeId");
	String firstName = req.getParameter("firstName");
	String middleName = req.getParameter("middleName");
	String lastName = req.getParameter("lastName");
	Boolean gender = ParamUtil.getBoolean(req, "gender");
	String jobTitle = req.getParameter("jobTitle");
	String street1 = req.getParameter("street1");
	String street2 = req.getParameter("street2");
	String street3 = req.getParameter("street3");
	String country = req.getParameter("countryId");
	String state = req.getParameter("regionId");
	String city = req.getParameter("cityId");
	String pinCode = req.getParameter("pinCode");
	String contactNo = req.getParameter("contactNo");
	String emailAddress = req.getParameter("emailId");
	String qualification = req.getParameter("qualification");
	String loginName = req.getParameter("loginName");
	int birthdayMonth = ParamUtil.getInteger(req, "birthdayMonth");
	int birthdayDay = ParamUtil.getInteger(req, "birthdayDay");
	int birthdayYear = ParamUtil.getInteger(req, "birthdayYear");
	Date birthDay = PortalUtil.getDate(
			birthdayMonth, birthdayDay, birthdayYear,
			new ContactBirthdayException());
	
	Staff staffEmailValidation = StaffLocalServiceUtil.getByEmail(emailAddress);
	try{
		validateScreenName(cId, loginName);
		
		if(Validator.isNotNull(staffEmailValidation)){
			throw new DuplicateUserEmailAddressException();
		}else{
			Staff staff = new StaffImpl();
			staff.setPrimaryKey(CounterUtil.increment(Teacher.class.getName()));
			staff.setEmployeeId(employeeId);
			staff.setCollegeId(Long.parseLong(collegeId));
			staff.setFirstName(firstName);
			staff.setMiddleName(middleName);
			staff.setLastName(lastName);
			staff.setGender(gender);
			staff.setBirthDay(birthDay);
			staff.setJobTitle(jobTitle);
			staff.setStreet1(street1);
			staff.setStreet2(street2);
			staff.setStreet3(street3);
			staff.setCountry(country);
			staff.setState(state);
			staff.setCity(city);
			staff.setPinCode(pinCode);
			staff.setContactNo(contactNo);
			staff.setEmailAddress(emailAddress);
			staff.setQualification(qualification);
			staff.setStatus(0);
			staff.setNew(true);
			staff.setCreateDate(new Date());
			staff.setLoginId(loginName);
			
			StaffLocalServiceUtil.getService().addStaff(staff);
			SessionMessages.add(req, "Registered Successfully");				
			
			setForward(req, "portlet.ext.registration.campus.success");
		}
	}catch(Exception e){
		if(e instanceof DuplicateUserEmailAddressException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else if(e instanceof ReservedUserScreenNameException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else if(e instanceof UserScreenNameException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else{
			throw e;
		}
		req.setAttribute("employeeId", employeeId);
		req.setAttribute("collegeId", collegeId);						
		setForward(req, "portlet.ext.registration.campus.staffForm");
	}
	}
	/**
	* @param req
	* @throws Exception
	*/
	private void validStaff(ActionRequest req) throws Exception {
	String employeeId = req.getParameter("employeeId").trim();
	String collegePin = req.getParameter("collegePin").trim();
	
	try{
		College college = CollegeLocalServiceUtil.secretPinValidation(collegePin);
		if(college != null){
			
			Staff staff = StaffLocalServiceUtil
								.staffValidation(college.getCollegeId(), employeeId);
			if(Validator.isNotNull(staff)){
				throw new DuplicateEmployeeIdException();
			}
			req.setAttribute("employeeId", employeeId);
			req.setAttribute("collegeId", String.valueOf(college.getCollegeId()));
			setForward(req, "portlet.ext.registration.campus.staffForm");
			
		}else{
			throw new SecretPinException();
		}
	}catch(Exception e){
		
		if(e instanceof SecretPinException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else if(e instanceof DuplicateEmployeeIdException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else{
			throw e;
		}
		req.setAttribute("employeeId", employeeId);
		req.setAttribute("collegePin", collegePin);						
		setForward(req, "portlet.ext.registration.campus.staff");					
	}
	}	
	
	/**
	* @param req
	* @param cId
	* @throws Exception 
	*/
	private void addCollStudent(ActionRequest req, long cId)
		throws Exception {
	String collegeId = req.getParameter("collegeId").trim();
	int birthdayMonth = ParamUtil.getInteger(req, "birthdayMonth");
	int birthdayDay = ParamUtil.getInteger(req, "birthdayDay");
	int birthdayYear = ParamUtil.getInteger(req, "birthdayYear");
	Date birthDay = PortalUtil.getDate(
			birthdayMonth, birthdayDay, birthdayYear,
			new ContactBirthdayException());
	String rollNo = req.getParameter("rollNo");
	String firstName = req.getParameter("firstName");
	String middleName = req.getParameter("middleName");
	String lastName = req.getParameter("lastName");
	Boolean gender = ParamUtil.getBoolean(req, "gender");
	String degree = req.getParameter("degree");
	String others = req.getParameter("others");
	String street1 = req.getParameter("street1");
	String street2 = req.getParameter("street2");
	String street3 = req.getParameter("street3");
	String country = req.getParameter("countryId");
	String state = req.getParameter("regionId");
	String city = req.getParameter("cityId");
	String pinCode = req.getParameter("pinCode");
	String contactNo = req.getParameter("contactNo");
	String loginName = req.getParameter("loginName");	
	
	
	try{
		validateScreenName(cId, loginName);
	
	 	CollStudent collstudent = new CollStudentImpl();
	 	collstudent.setPrimaryKey(CounterUtil.increment(CollStudent.class.getName()));
	 	collstudent.setCollegeId(Long.parseLong(collegeId));
	 	collstudent.setRollNo(rollNo);
	 	collstudent.setFirstName(firstName);
	 	collstudent.setMiddleName(middleName);
	 	collstudent.setLastName(lastName);
	 	collstudent.setLoginId(loginName);
	 	collstudent.setGender(gender);
	 	collstudent.setBirthDay(birthDay);
	 	collstudent.setDegree(degree);
	 	collstudent.setOthers(others);
	 	collstudent.setStreet1(street1);
	 	collstudent.setStreet2(street2);
	 	collstudent.setStreet3(street3);
	 	collstudent.setCountry(country);
	 	collstudent.setState(state);
	 	collstudent.setCity(city);
	 	collstudent.setPinCode(pinCode);
	 	collstudent.setContactNo(contactNo);
	 	collstudent.setStatus(0);
	 	collstudent.setCreateDate(new Date());
	 	collstudent.setNew(true);
		
		CollStudentLocalServiceUtil.getService().addCollStudent(collstudent);
		SessionMessages.add(req, "Registered Successfully");				
		
		setForward(req, "portlet.ext.registration.campus.success");							
	
		
	}catch(Exception ex){
		
		if(ex instanceof DuplicateUserScreenNameException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else if(ex instanceof ReservedUserScreenNameException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else if(ex instanceof UserScreenNameException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else {
			throw ex;
		}
		req.setAttribute("collStudentId", rollNo);
		req.setAttribute("collegeId", collegeId);
		setForward(req, "portlet.ext.registration.campus.collStudentForm");
	}			
	}
	/**
	* @param req
	* @throws Exception
	*/
	private void validCollStudent(ActionRequest req) throws Exception {
	String collStudentId = req.getParameter("collStudentId").trim();
	String collegePin = req.getParameter("collegePin").trim();
	
	try{
		College college = CollegeLocalServiceUtil.secretPinValidation(collegePin);
		if(college != null){
			CollStudent collstudent = CollStudentLocalServiceUtil
							.collStudentValidation(college.getCollegeId(), collStudentId);
			if(collstudent != null){
				throw new DuplicateRollNoException();
			}
			req.setAttribute("collStudentId", collStudentId);
			req.setAttribute("collegeId", String.valueOf(college.getCollegeId()));
			setForward(req, "portlet.ext.registration.campus.collStudentForm");
			
		}else{
			throw new SecretPinException();
		}
	}catch(Exception e){
		
		if(e instanceof SecretPinException){
			SessionErrors.add(req, e.getClass().getName(), e);
		}else if(e instanceof DuplicateRollNoException) {
			SessionErrors.add(req, e.getClass().getName(), e);
		}else{
			throw e;
		}
		setForward(req, "portlet.ext.registration.campus.collStudent");					
	}
	}
	/**
	* @param req
	* @param cId
	* @throws Exception
	*/
	private void addCollege(ActionRequest req, long cId) throws Exception {
	String name = req.getParameter("name");
	String street1 = req.getParameter("street1");
	String street2 = req.getParameter("street2");
	String street3 = req.getParameter("street3");
	String university = req.getParameter("university");
	String countryId = req.getParameter("countryId");
	String regionId = req.getParameter("regionId");
	String cityId = req.getParameter("cityId");
	String cityIdText = req.getParameter("cityIdText");
	String pinCode = req.getParameter("pinCode");
	String contactNo = req.getParameter("contactNo");
	String webSite = req.getParameter("webSite");
	
	Integer noOfStudents = ParamUtil.getInteger(req, "noOfStudents");
	Integer noOfStaffs = ParamUtil.getInteger(req, "noOfStaffs");
	String firstName = req.getParameter("firstName");
	String middleName = req.getParameter("middleName");
	String lastName = req.getParameter("lastName");
	Boolean gender = ParamUtil.getBoolean(req, "gender");
	String jobTitle = ParamUtil.getString(req, "jobTitle");
	String cpContactNo = req.getParameter("cpContactNo");
	String cpEmailAddress = req.getParameter("cpEmailAddress").trim();
	String loginName = req.getParameter("loginName");
	
	int birthdayMonth = ParamUtil.getInteger(req, "birthdayMonth");
	int birthdayDay = ParamUtil.getInteger(req, "birthdayDay");
	int birthdayYear = ParamUtil.getInteger(req, "birthdayYear");
	Date dateOfEstablishment = PortalUtil.getDate(
			birthdayMonth, birthdayDay, birthdayYear,
			new ContactBirthdayException());
	
	int birthDayMonth = ParamUtil.getInteger(req, "birthDayMonth");
	int birthDayDay = ParamUtil.getInteger(req, "birthDayDay");
	int birthDayYear = ParamUtil.getInteger(req, "birthDayYear");
	Date birthDay = PortalUtil.getDate(
			birthDayMonth, birthDayDay, birthDayYear,
			new ContactBirthdayException());
	
	try{
		validateScreenName(cId, loginName);
		validateName(name);
		//validateFriendlyURL(name);
		College college1 = CollegeLocalServiceUtil.getByEmail(cpEmailAddress); 
		
		if(Validator.isNotNull(college1)){						
		throw new DuplicateUserEmailAddressException();
	    } else{
			College college = new CollegeImpl();
			college.setPrimaryKey(CounterUtil.increment(College.class.getName()));
			college.setName(name);
			college.setDateOfEstablishment(dateOfEstablishment);
			college.setStreet1(street1);
			college.setStreet2(street2);
			college.setStreet3(street3);
			college.setUniversity(university);
			college.setCountry(countryId);
			college.setState(regionId);
			college.setCity(cityId == null? cityIdText : cityId);
			college.setPinCode(pinCode);
			college.setContactNo(contactNo);
			college.setWebsite(webSite);
			college.setCpEmailAddress(cpEmailAddress);
			college.setNoOfStudents(noOfStudents);
			college.setNoOfStaffs(noOfStaffs);
			college.setCpFirstName(firstName);
			college.setCpMiddleName(middleName);
			college.setCpLastName(lastName);
			college.setCpGender(gender);
			college.setBirthDay(birthDay);
			college.setJobTitle(jobTitle);
			college.setCpContactNo(cpContactNo);
			college.setLoginId(loginName);
			
			//school.setDateOfEstablishment(dateOfEstablishment);
			college.setCreateDate(new Date());
			college.setStatus(0);
			college.setIpAddress(req.getRemoteUser());
			college.setNew(true);
			
			CollegeLocalServiceUtil.getService().addCollege(college);
			SessionMessages.add(req, "Registered Successfully");				
			
			setForward(req, "portlet.ext.registration.campus.success");						
	    	}	
		
		
	}catch(Exception ex){
		if(ex instanceof DuplicateUserScreenNameException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else if(ex instanceof ReservedUserScreenNameException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else if(ex instanceof UserScreenNameException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else if(ex instanceof DuplicateUserEmailAddressException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else if(ex instanceof GroupNameException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else if(ex instanceof GroupFriendlyURLException){
			SessionErrors.add(req, ex.getClass().getName(), ex);
			
		}else {
			throw ex;
		}
		setForward(req, "portlet.ext.registration.campus.collegeForm");
		
	}	
					
	}
	
	//pending and reject
	
	private void pendingCollege(ActionRequest req) throws PortalException, SystemException {
	Long collegeId = Long.parseLong(req.getParameter("collegeId"));				
	College college = CollegeLocalServiceUtil.getCollege(collegeId);
	college.setStatus(2);
	CollegeLocalServiceUtil.updateCollege(college);
	setForward(req, "portlet.ext.registration.view");
	}
	
	private void rejectCollege(ActionRequest req) throws PortalException, SystemException {
	Long collegeId = Long.parseLong(req.getParameter("collegeId"));				
	College college = CollegeLocalServiceUtil.getCollege(collegeId);
	college.setStatus(3);
	CollegeLocalServiceUtil.updateCollege(college);
	setForward(req, "portlet.ext.registration.view");
	}
	
	private void pendingCollStudent(ActionRequest req) throws PortalException, SystemException {
	Long collStudentId = Long.parseLong(req.getParameter("collStudentId"));				
	CollStudent collStudent = CollStudentLocalServiceUtil.getCollStudent(collStudentId);
	collStudent.setStatus(2);
	CollStudentLocalServiceUtil.updateCollStudent(collStudent);
	setForward(req, "portlet.ext.registration.view");
	}
	
	private void rejectCollStudent(ActionRequest req) throws PortalException, SystemException {
	Long collStudentId = Long.parseLong(req.getParameter("collStudentId"));				
	CollStudent collStudent = CollStudentLocalServiceUtil.getCollStudent(collStudentId);
	collStudent.setStatus(3);
	CollStudentLocalServiceUtil.updateCollStudent(collStudent);
	setForward(req, "portlet.ext.registration.view");
	}
	
	private void pendingStaff(ActionRequest req) throws PortalException, SystemException {
	Long staffId = Long.parseLong(req.getParameter("staffId"));				
	Staff staff = StaffLocalServiceUtil.getStaff(staffId);
	staff.setStatus(2);
	StaffLocalServiceUtil.updateStaff(staff);
	setForward(req, "portlet.ext.registration.view");
	}
	
	private void rejectStaff(ActionRequest req) throws PortalException, SystemException {
	Long staffId = Long.parseLong(req.getParameter("staffId"));				
	Staff staff = StaffLocalServiceUtil.getStaff(staffId);
	staff.setStatus(3);
	StaffLocalServiceUtil.updateStaff(staff);
	setForward(req, "portlet.ext.registration.view");
	}
	
	private void pendingCollOthers(ActionRequest req) throws PortalException, SystemException {
	Long collOthersId = Long.parseLong(req.getParameter("collOthersId"));				
	CollOthers collOthers = CollOthersLocalServiceUtil.getCollOthers(collOthersId);
	collOthers.setStatus(2);
	CollOthersLocalServiceUtil.updateCollOthers(collOthers);
	setForward(req, "portlet.ext.registration.view");
	}
	
	private void rejectCollOthers(ActionRequest req) throws PortalException, SystemException {
	Long collOthersId = Long.parseLong(req.getParameter("collOthersId"));				
	CollOthers collOthers = CollOthersLocalServiceUtil.getCollOthers(collOthersId);
	collOthers.setStatus(3);
	CollOthersLocalServiceUtil.updateCollOthers(collOthers);
	setForward(req, "portlet.ext.registration.view");
	}
		// Method to approve the account
		protected User createUser(
	            long companyId, String screenName, String firstName,
	            String middleName, String lastName, boolean male, 
	            int birthdayMonth, int birthdayDay, int birthdayYear, String emailAdd,String jobTitle, String comments)
	        throws Exception {
			long[] roleIds = {};
	        long creatorUserId = 0;
	        boolean autoPassword = false;
	        String password1 = screenName;
	        String password2 = password1;
	        boolean autoScreenName = false;
	        String emailAddress = emailAdd;
	        String openId = StringPool.BLANK;
	        Locale locale = Locale.US;
	        //String jobTitle = StringPool.BLANK;
	        int prefixId = 0;
	        int suffixId = 0;
	        
	        long[] groupIds = null;
	
	        long[] emptyLong = {};
	        
	        long[] userGroupIds = null;
	        boolean sendEmail = false;
	        ServiceContext serviceContext = null;
	
	        User user = UserLocalServiceUtil.addUser(
	            creatorUserId, companyId, autoPassword, password1, password2,
	            autoScreenName, screenName, emailAddress, openId, locale, firstName,
	            middleName, lastName, prefixId, suffixId, male, birthdayMonth,
	            birthdayDay, birthdayYear, jobTitle, groupIds, emptyLong,
	            roleIds, userGroupIds, sendEmail, serviceContext);
	        user.setComments(comments);
	        UserLocalServiceUtil.updateUser(user);
		 return user;
		
		}
											
		protected String getFriendlyURL(String friendlyURL) {
			friendlyURL = GetterUtil.getString(friendlyURL);
	
			return FriendlyURLNormalizer.normalize(friendlyURL);
		}
		
		protected void validateFriendlyURL(String friendlyURL)
			throws PortalException, SystemException {
	
			if (Validator.isNull(friendlyURL)) {
				return;
			}
	
			int exceptionType = LayoutImpl.validateFriendlyURL(friendlyURL);
	
			if (exceptionType != -1) {
				throw new GroupFriendlyURLException(exceptionType);
			}				
		}

	private static Log log = LogFactory.getLog(CampusRegistration.class);
}
